#!/usr/bin/python
# -*- coding: utf-8 -*-

import unittest
import mintweek

class WeekTest(unittest.TestCase):
	_knownWeeks = ((1, "2008-01-06"), 
			(4, "2008-01-22"),
			(9, "2008-03-01"),
			(24, "2008-06-11"),
			(45, "2008-11-08"),
			(52, "2008-12-26"),
			(52, "2008-12-28"),
			(1, "2008-12-29"),
			(1, "2008-01-04"),
			(51, "2009-12-20"),
			(52, "2009-12-21"),
			(52, "2009-12-27"),
			(53, "2009-12-28"),
			(53, "2010-01-03"))

	_knownWeeksWithDates = (("2007-12-17", "2007-12-23", "2007-12-20"),
			("2007-12-31", "2008-01-06", "2008-01-03"),
			("2008-11-24", "2008-11-30", "2008-11-27"),
			("2008-12-29", "2009-01-04", "2009-01-01"),
			("2008-06-30", "2008-07-06", "2008-06-30"),
			("2008-06-30", "2008-07-06", "2008-07-06"))

	_knownShortNames = (("01.2008", "2008-01-06"), 
			("24.2008", "2008-06-11"),
			("52.2008", "2008-12-28"),
			("53.2009", "2009-12-28"))

	_knownLongNames = (("Неделя 1 (31.12.2007 - 06.01.2008)", "2008-01-01"),
			("Неделя 28 (07.07.2008 - 13.07.2008)", "2008-07-08"))

	def test_weekcreation(self):
		for weekNumber, date in self._knownWeeks:
			week = mintweek.Week(date)
			self.assertEqual(weekNumber, week.number)

	def test_weekdates(self):
		for startDate, endDate, date in self._knownWeeksWithDates:
			week = mintweek.Week(date)
			self.assertEqual(startDate, week.startDate)
			self.assertEqual(endDate, week.endDate)

	def test_weekshortnames(self):
		for shortName, date in self._knownShortNames:
			week = mintweek.Week(date)
			self.assertEqual(shortName, week.shortName)

	def test_weeklongnames(self):
		for longName, date in self._knownLongNames:
			week = mintweek.Week(date)
			self.assertEqual(longName, week.longName)


if __name__ == "__main__":
	unittest.main()
